# Maintainer: David Runge <dvzrv@archlinux.org>

_name=robot-detection
pkgname=python-robot-detection
pkgver=0.4.0
pkgrel=7
pkgdesc="Detect web crawlers using HTTP User Agent"
arch=('any')
url="https://github.com/rory/robot-detection"
license=('GPL3')
depends=('python-six')
makedepends=('python-setuptools')
checkdepends=('python-pytest')
# sdist doesn't contain tests:
# https://github.com/rory/robot-detection/issues/2
source=("$pkgname-$pkgver.tar.gz::https://github.com/rory/${_name}/archive/v${pkgver}.tar.gz")
sha512sums=('10b1fbd2307c375e3cd067e43bee1bc0ff71f4b83ede9b92d2fb8d60edfd6d4a8d1a4d06d74e3c0653056f2e2b2cb81a7e997047093e925bd79bf4626d33d85f')

prepare() {
  mv -v "${_name}-${pkgver}" "$pkgname-$pkgver"
}

build() {
  cd "$pkgname-$pkgver"
  python setup.py build
}

check() {
  cd "$pkgname-$pkgver"
  export PYTHONPATH="${PWD}/build:${PYTHONPATH}"
  python ./tests.py
}

package() {
  cd "$pkgname-$pkgver"
  python setup.py install --skip-build \
    --optimize=1 \
    --prefix=/usr \
    --root="${pkgdir}"
  install -vDm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
}
